from wcs.libs.players import players
from wcs.libs.items import items

itemName = "Ring of Regeneration"
item = items.addItem(itemName)
item.setGroup("defense")
item.setCost(4000)
item.setDescription("Regain health over time")
item.setMaxCount(1)
item.aliveToUse = True

def wcs_item_bought(event_var):
    """
    Executed when a player has purchased an item. If the item purcahsed was this
    item, then ensure that we begin the regeneration
    """
    if event_var['item'] == itemName:
        userid = event_var["userid"]
        player = players[userid]
        player.regen(2, 1)